// 基础卡片提取器接口
export class BaseCardExtractor {
  constructor(selectors) {
    this.selectors = selectors;
  }

  // 获取卡片选择器
  getCardSelector() {
    return this.selectors.card;
  }

  // 提取卡片数据
  extract(cardElement) {
    const label = this.extractLabel(cardElement);
    const value = this.extractValue(cardElement);
    const changeData = this.extractChangeData(cardElement);
    
    if (label || value) {
      return {
        label,
        value,
        ...changeData
      };
    }
    return null;
  }

  // 提取标签
  extractLabel(cardElement) {
    return cardElement.querySelector(this.selectors.name)?.textContent.trim() || '';
  }

  // 提取值
  extractValue(cardElement) {
    return cardElement.querySelector(this.selectors.value)?.textContent.trim() || '';
  }

  // 提取变化数据
  extractChangeData(cardElement) {
    const changeTitle = cardElement.querySelector(this.selectors.changeTitle)?.textContent.trim();
    const changeValue = cardElement.querySelector(this.selectors.changeValue)?.textContent.trim();
    
    if (changeTitle && changeValue) {
      return { [changeTitle]: changeValue };
    }
    return {};
  }
} 